<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class BaseController extends Controller
{
    //
    protected $pagesize = 10;

    public function __construct()
    {
        //从配置文件中读取分页的页码大小
        $this->pagesize = config('page.pagesize');
    }

    public function response($code = 200, $msg = "成功", $data = [])
    {
        $res = ['code' => $code, 'msg' => $msg, 'data' => $data];
        exit(json_encode($res));
    }

    public function success($data = [], $code = 200, $msg = "操作成功")
    {
        $this->response($code, $msg, $data);
    }

    public function fail($code = 400, $msg = "操作失败", $data = [])
    {
        $this->response($code, $msg, $data);
    }
}
